<?php

    include("header_login_required.php");

?>



<?php

    $user = $_SESSION['user'];

    mysql_connect(DB_SERVER, DB_USER, DB_PWD);

  	mysql_select_db(DB_CATALOG);



    $result = mysql_query("select count(1) as isPresent from zt_club_info where club_id = ".$user->club_id);

    $row = mysql_fetch_assoc($result);

    $isPresent = $row['isPresent'];



    $result = mysql_query("select clubname from club where club_id = ".$user->club_id);

    $row = mysql_fetch_assoc($result);

    $clubname = $row['clubname'];



    $success = false;

    if ( isset($_POST['site']) ) {

		$site = $_POST['site'];

		$site_address = $_POST['site_address'];

		$site_city = $_POST['site_city'];

		$site_phone = $_POST['site_phone'];

		$play_day = $_POST['play_day'];

		$contact_name = $_POST['contact_name'];

		$contact_address = $_POST['contact_address'];

		$contact_city = $_POST['contact_city'];

		$contact_phone = $_POST['contact_phone'];

		$contact_email = $_POST['contact_email'];



		if ( empty($site) || empty($site_address) || empty($site_city) || empty($site_city) || empty($site_phone) ||

				empty($play_day) || empty($contact_name) || empty($contact_address) || empty($contact_city) || empty($contact_phone) ||

				empty($contact_email) ) {



        	echo "<center><strong style='color:#FFFFFF'>Niet alle velden zijn ingevuld.<strong><center>";



        } else {

            $result = mysql_query("select count(1) as isPresent from zt_club_info where club_id = ".$user->club_id);

            $row = mysql_fetch_assoc($result);

            $isPresent = $row['isPresent'];



            if ($isPresent == 0) {

            	// insert

                $query = sprintf("INSERT INTO zt_club_info (club_id, site, address, city, phone, play_day, contact_name,

                	contact_address, contact_city, contact_phone, contact_email) VALUES (%u, '%s', '%s', '%s', '%s', '%s',

                	'%s', '%s', '%s', '%s', '%s')", $user->club_id, mysql_real_escape_string($site),

	                mysql_real_escape_string($site_address), mysql_real_escape_string($site_city),

	                mysql_real_escape_string($site_phone), mysql_real_escape_string($play_day),

	                mysql_real_escape_string($contact_name), mysql_real_escape_string($contact_address),

	                mysql_real_escape_string($contact_city), mysql_real_escape_string($contact_phone),

	                mysql_real_escape_string($contact_email));



	            $result = mysql_query($query);

	            $success = true;

            } else {

            	// update

                $query = sprintf("UPDATE zt_club_info SET site = '%s', address = '%s', city = '%s', phone = '%s',

                	play_day = '%s', contact_name = '%s', contact_address = '%s', contact_city = '%s',

	                contact_phone = '%s', contact_email = '%s' WHERE club_id = %u", mysql_real_escape_string($site),

	                mysql_real_escape_string($site_address), mysql_real_escape_string($site_city),

	                mysql_real_escape_string($site_phone), mysql_real_escape_string($play_day),

	                mysql_real_escape_string($contact_name), mysql_real_escape_string($contact_address),

	                mysql_real_escape_string($contact_city), mysql_real_escape_string($contact_phone),

	                mysql_real_escape_string($contact_email), $user->club_id);



	            $result = mysql_query($query);

	            $success = true;

            }

        }

    } else {

        $query = sprintf("SELECT site, address, city, phone, play_day, contact_name, contact_address, contact_city,

	        contact_phone, contact_email FROM zt_club_info WHERE club_id = '%u'", $user->club_id);

	    $result = mysql_query($query);

	    $row = mysql_fetch_assoc($result);



	    $site = $row['site'];

	    $site_address = $row['address'];

	    $site_city = $row['city'];

	    $site_phone = $row['phone'];

	    $play_day = $row['play_day'];

	    $contact_name = $row['contact_name'];

	    $contact_address = $row['contact_address'];

	    $contact_city = $row['contact_city'];

	    $contact_phone = $row['contact_phone'];

	    $contact_email = $row['contact_email'];

    }

?>



<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0" bgcolor="#FFFFFF">



	<tr>

		<td id="leftFiller" valign="top" height="100%" rowspan="3" bgcolor="#666666">

			<table border="0" cellpadding="0" cellspacing="0" height="100%" width="8px">

				<tr><td>&nbsp;</td></tr>

			</table>

		</td>

		<td id="header" valign="top" width="100%">

			<table border="0" width="100%" cellpadding="3" cellspacing="0" bgcolor="#10425b">
                <tr>
                    <td bgcolor="#666666" width="40%">
                        <?php include("inc_title.html"); ?>
                    </td>
                    <td bgcolor="#666666" align="right" valign="top">&nbsp;
                          <span class="headerSmall">Huidige versie PLAYER.DBF: <?=CURRENT_PLAYER_DBF?>
                        <?php
                        if (isset($user) && $user->club_id == 100) {
                        ?>
                        <br/>
                        <a class="headerSmall" href="import_player.php">laad andere versie</a>
                        <?php
                        }
                        ?>
                        </span>
                    </td>
                </tr>
            </table>
            <table align="center" border="0" width="100%" height="90%" cellpadding="0" cellspacing="0" style="border-top:#BCDD10 4px solid;">
                <tr>
                    <?php include("inc_sublinks.php"); ?> 
                </tr>

				<tr><td colspan="2" nowrap bgcolor="#BCDD10" height="4"><img src="../../assets/images/spacer.gif" alt="" height="1" width="1"></td></tr>

				<tr>

					<td>&nbsp;</td>

					<td valign="top">

						<table align="left" cellspacing="10" width="100%">

							<tr>

								<td>

                                <span class="blackHeaderLarge">Zilveren Toren <?=CURRENT_ZT_YEAR?> - Contactinfo '<?=$clubname?>'</span>

                                <br/>

									<form action="" method="post">

                                    <table cellspacing="5" class="yellowBox">

                                        <tr style="background-color:#A6C218">

                                             <td colspan="2"><strong>Clubinformatie</strong></td>

                                    	</tr>

                                    	<tr>

                                    		<td width="30%"><strong>Nummer</strong></td>

                                    		<td><strong><?= $user->club_id ?></strong></td>

                                    	</tr>

                                        <tr>

                                    		<td><strong>Naam lokaal</strong></td>

                                    		<td><input name="site" type="text" size="35" value="<?= $site ?>"/></td>

                                    	</tr>

                                        <tr>

                                    		<td><strong>Straatnaam + nr</strong></td>

                                    		<td><input name="site_address" type="text" size="50" value="<?= $site_address ?>"/></td>

                                    	</tr>

                                        <tr>

                                    		<td><strong>Postcode + gemeente</strong></td>

                                    		<td><input name="site_city" type="text" size="50" value="<?= $site_city ?>"/></td>

                                    	</tr>

                                        <tr>

                                    		<td><strong>Telefoon</strong></td>

                                    		<td><input name="site_phone" type="text" size="50" value="<?= $site_phone ?>"/></td>

                                    	</tr>

                                        <tr>

                                    		<td><strong>Speeldag</strong></td>

                                    		<td><input name="play_day" type="text" size="20" value="<?= $play_day ?>"/></td>

                                    	</tr>

                                    	<tr style="background-color:#A6C218">

                                             <td colspan="2"><strong>Ploegleiderinformatie</strong></td>

                                    	</tr>

                                        <tr>

                                    		<td><strong>Naam</strong></td>

                                    		<td><input name="contact_name" type="text" size="30" value="<?= $contact_name ?>"/></td>

                                    	</tr>

                                        <tr>

                                    		<td><strong>Adres</strong></td>

                                    		<td><input name="contact_address" type="text" size="30" value="<?= $contact_address ?>"/></td>

                                    	</tr>

                                        <tr>

                                    		<td><strong>Gemeente</strong></td>

                                    		<td><input name="contact_city" type="text" size="30" value="<?= $contact_city ?>"/></td>

                                    	</tr>

                                        <tr>

                                    		<td><strong>Telefoon</strong></td>

                                    		<td><input name="contact_phone" type="text" size="30" value="<?= $contact_phone ?>"/></td>

                                    	</tr>

                                        <tr>

                                    		<td><strong>E-mail</strong></td>

                                    		<td><input name="contact_email" type="text" size="30" value="<?= $contact_email ?>"/></td>

                                    	</tr>

                                        <tr>

											<td colspan="2"><input type="submit" value="Wijzig gevens" class="submit"/></td>

										</tr>

	                                </table>

	                                </form>

								</td>

							</tr>

                            <tr>

								<td><a href="/tornooien/zt-php/zt_clubs.php"><img border="0" src="../../assets/images/24x24/shadow/home.gif">

								<strong style="font-size:11px">Toon clubinfo</strong></a></td>

							</tr>

							<?php

                            	if ($success) {

                            ?>

                            <tr>

								<td><strong style="background-color:#FFFFCC">ZT contactgegevens zijn gewijzigd (<a href="zt_club_info_detail.php?club_id=<?=$user->club_id?>">detail</a>).</strong></td>

							</tr>

                            <?php

                                }

							?>

						</table>

					</td>

				</tr>

			</table>

		</td>

	</tr>

</table>



<?php include("footer.php") ?>

